package com.sskj.hhhjys.util;

import android.content.Context;
import android.graphics.Color;
import android.support.design.widget.BottomSheetDialog;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;

import com.afollestad.materialdialogs.MaterialDialog;
import com.sskj.common.base.App;
import com.sskj.common.util.ClickUtil;
import com.sskj.common.util.ToastUtil;
import com.sskj.hhhjys.R;

public class AppTipUtil {


    public static BottomSheetDialog showGoogleCheckDialog(Context context, OnTipPwdSure onTipPwdSure) {

        BottomSheetDialog dialog = new BottomSheetDialog(context);
        View rootView = LayoutInflater.from(context).inflate(R.layout.app_dialog_google_check, null, false);
        View customView = rootView;
        TextView tvCancel = customView.findViewById(R.id.tvCancel);
        EditText etPwd = customView.findViewById(R.id.etPwd);
        ClickUtil.click(customView.findViewById(R.id.btSubmit), () -> {
            if (TextUtils.isEmpty(etPwd.getText())) {
                ToastUtil.showShort(App.INSTANCE.getString(R.string.appJavaAppTipUtil1));
                return;
            }
            onTipPwdSure.onSure(etPwd.getText().toString());
        });
        ClickUtil.click(tvCancel, () -> {
            dialog.dismiss();
        });

        dialog.setContentView(rootView);
        dialog.setCancelable(true);
        dialog.setCanceledOnTouchOutside(true);
        return dialog;

//        ((ViewGroup) (customView.getParent())).setBackgroundColor(Color.TRANSPARENT);
//        ((ViewGroup) (customView.getParent().getParent())).setBackgroundColor(Color.TRANSPARENT);
//        ((ViewGroup) (customView.getParent().getParent().getParent())).setBackgroundColor(Color.TRANSPARENT);
//        ((ViewGroup) (customView.getParent().getParent().getParent().getParent())).setBackgroundColor(Color.TRANSPARENT);
//        ((ViewGroup) (customView.getParent().getParent().getParent().getParent().getParent())).setBackgroundColor(Color.TRANSPARENT);
//
//        return dialog;
    }

    public interface OnTipSure {
        void onSure();
    }

    public interface OnTipPwdSure {
        void onSure(String pwd);
    }
}
